﻿@using ZBJF.Warranty.WebProvider
@{
    ViewBag.Title = "Index";
}
@section Header{
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
}
<ul class="nav nav-tabs">
    <li class="active"><a href="/ProductType/">设备类型列表</a></li>
    <li class="Add-R"><a  href="/ProductType/Edit/0">添加设备类型</a></li>
</ul>
<form id="searchForm" class="breadcrumb form-search">
    <div>
        <label>是否可用：</label>
        @Html.DropDownList("IsAvailable", ConvertToSelector.Instance.InitSelectList(true), new { @class = "tag-input-style" })
        <label>关键词：</label><input id="Keyword" name="Keyword" class="input-medium" placeholder="请输入搜索关键词" type="text" value="" maxlength="50" />
        <input id="btnSubmit" class="btn btn-primary Search-R" type="button" value="查询" onclick="search();">
    </div>
</form>
<div class="table-responsive dataTables_wrapper">
    <table id="productTypeList" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th width="20">序号</th>
                <th width="100">设备类型名称</th>
                <th width="100">设备类型编码</th>
                <th width="80">修改时间</th>
                <th width="100">排序</th>
                <th width="80">是否可用</th>
                <th width="100">操作</th>
            </tr>
        </thead>
    </table>
</div>
@section scripts{
    @Scripts.Render("~/Bundles/ImagePreview")
    <script type="text/javascript">
        var isSearch = false;
        $(function () {
            var objTable = $("#productTypeList")
                .dataTable({
                    fnDrawCallback: function () {
                        ControlPermissionOperate();
                    },
                    "sAjaxSource": "/ProductType",
                    aoColumns: [
                        {
                            "mData": null, "bSortable": false, "fnRender": function (nRow) {
                                return nRow.iDataRow + 1;
                            }
                        },
                        {
                            "mData": "ProductName", "bSortable": false, "fnRender": function (nRow) {
                                return "<a class='Edit-R' href='/ProductType/Edit/" + nRow.aData.ID + "' title='edit'>" + nRow.aData.ProductName + "</a>";
                            }
                        },
                        { "mData": "ProductCode", "bSortable": false },
                        { "mData": "LastModifyTime" },
                        { "mData": "Sort" },
                         { "mData": "IsAvailable" },
                        { "mData": "ID", "bSortable": false }
                    ],
                    "fnRowCallback": function (nRow, aData, iDisplayIndex) {
                        $('td:eq(5)', nRow).html(aData.IsAvailable ? bootStrapOkIncon : bootStrapRemoveIncon);
                        var html = "<a class='Edit-R' href='/ProductType/Edit/" + aData.ID + "' title='edit'><i class='icon-edit'></i></a>";
                        html += "<a class='Edit-R' href=\"javascript:UpdateStatus('" + aData.ID + "'," + !aData.IsAvailable + ",'/ProductType/UpdateStatus','productTypeList')\" title='" + (aData.IsAvailable ? "禁用" : "启用") + "'>" + (aData.IsAvailable ? bootStrapRemoveIncon : bootStrapOkIncon) + "</a>";
                        $('td:eq(6)', nRow).html(html);
                    }
                });
            imgPreview();
        });

        function imgPreview() {
            setTimeout(function () { $("img.preview").preview(); }, 500);
        }
        function search() {
            /*给查询对象赋值*/
            queryParamList.Keyword = ($("#Keyword").val()).trim();
            queryParamList.IsAvailable = $("#IsAvailable").val();
            $("#productTypeList").dataTable().fnDraw();
            imgPreview();
        }

    </script>
}


